package com.atguigu.test;

import com.atguigu.config.MainConfig5;
import com.atguigu.dao.BookDao;
import com.atguigu.service.BookService;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class IOCTestAutowired {

    AnnotationConfigApplicationContext applicationContext
            = new AnnotationConfigApplicationContext(MainConfig5.class);

    @Test
    public void test01() {
        //!!!!bookDao有两个实现
        BookService bookService = applicationContext.getBean(BookService.class);
        System.out.println(bookService);

        BookDao bookDao = (BookDao) applicationContext.getBean("bookDao");
        System.out.println(bookDao);
    }
}
